<?php 
 include_once dirname(__FILE__)."/config.php";
 class fiche_evaluation_principal{
		 protected $_result;
		 protected $_cnn;
		 protected $_code_fiche;
		 protected $_code_depot;
		 protected $_CIN;
		 protected $_date_envoi_eval;
		 protected $_daye_reception_rapport;
		 protected $_date_RE_concepteur;
		 protected $_observation;
		 protected $_decision;
		 public function get_name_table(){ return "fiche_evaluation";}
		 public function get_name_code_fiche(){ return "code_fiche";}
		 public function get_name_code_depot(){ return "code_depot";}
		 public function get_name_CIN(){ return "CIN";}
		 public function get_name_date_envoi_eval(){ return "date_envoi_eval";}
		 public function get_name_daye_reception_rapport(){ return "daye_reception_rapport";}
		 public function get_name_date_RE_concepteur(){ return "date_RE_concepteur";}
		 public function get_name_observation(){ return "observation";}
		 public function get_name_decision(){ return "decision";}
		 public function set_code_fiche($parametre){  $this->_code_fiche=$parametre;}	
		 public function set_code_depot($parametre){  $this->_code_depot=$parametre;}	
		 public function set_CIN($parametre){  $this->_CIN=$parametre;}	
		 public function set_date_envoi_eval($parametre){  $this->_date_envoi_eval=$parametre;}	
		 public function set_daye_reception_rapport($parametre){  $this->_daye_reception_rapport=$parametre;}	
		 public function set_date_RE_concepteur($parametre){  $this->_date_RE_concepteur=$parametre;}	
		 public function set_observation($parametre){  $this->_observation=$parametre;}	
		 public function set_decision($parametre){  $this->_decision=$parametre;}	
		 public function get_result(){ return $this->_result;}
		 public function get_code_fiche(){ return $this->_code_fiche;}
		 public function get_code_depot(){ return $this->_code_depot;}
		 public function get_CIN(){ return $this->_CIN;}
		 public function get_date_envoi_eval(){ return $this->_date_envoi_eval;}
		 public function get_daye_reception_rapport(){ return $this->_daye_reception_rapport;}
		 public function get_date_RE_concepteur(){ return $this->_date_RE_concepteur;}
		 public function get_observation(){ return $this->_observation;}
		 public function get_decision(){ return $this->_decision;}
public function __construct(){

		 	$this->_cnn=new databaseconnect();

		 }

 public function INSERT()
{

$sql=" INSERT INTO 
 fiche_evaluation(
			code_depot,
			CIN,
			date_envoi_eval,
			daye_reception_rapport,
			date_RE_concepteur,
			observation,
			decision)
 VALUES(
			'".$this->_code_depot."',
			'".$this->_CIN."',
			'".$this->_date_envoi_eval."',
			'".$this->_daye_reception_rapport."',
			'".$this->_date_RE_concepteur."',
			'".$this->_observation."',
			'".$this->_decision."')";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function UPDATE()
{

 $sql="";
if(!empty($this->_code_depot)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
code_depot='".$this->_code_depot."'";
}
if(!empty($this->_CIN)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
CIN='".$this->_CIN."'";
}
if(!empty($this->_date_envoi_eval)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
date_envoi_eval='".$this->_date_envoi_eval."'";
}
if(!empty($this->_daye_reception_rapport)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
daye_reception_rapport='".$this->_daye_reception_rapport."'";
}
if(!empty($this->_date_RE_concepteur)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
date_RE_concepteur='".$this->_date_RE_concepteur."'";
}
if(!empty($this->_observation)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
observation='".$this->_observation."'";
}
if(!empty($this->_decision)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
decision='".$this->_decision."'";
}
$sql="UPDATE 
fiche_evaluation SET 
 ".$sql."
								WHERE code_fiche ='".$this->_code_fiche."'";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function DELETE(){

 $sql="DELETE FROM 
fiche_evaluation 
 
									WHERE code_fiche ='".$this->_code_fiche."'";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function TRANCATE(){

 $sql="DELETE FROM 
fiche_evaluation ";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function SELECT($constraint="",$pagination="")
{

$sql=" SELECT 
 		code_fiche,
		code_depot,
		CIN,
		date_envoi_eval,
		daye_reception_rapport,
		date_RE_concepteur,
		observation,
		decision
 FROM 
 fiche_evaluation";
if($constraint){$sql.=" WHERE 1=1 ".$constraint;}if($pagination){$sql.=$pagination;}
$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}
public function fetch_object(){
$row=mysql_fetch_object($this->_result);
 if($this->_result){
 if($row){
		$this->_code_fiche=$row->code_fiche;
		$this->_code_depot=$row->code_depot;
		$this->_CIN=$row->CIN;
		$this->_date_envoi_eval=$row->date_envoi_eval;
		$this->_daye_reception_rapport=$row->daye_reception_rapport;
		$this->_date_RE_concepteur=$row->date_RE_concepteur;
		$this->_observation=$row->observation;
		$this->_decision=$row->decision;
		return $row;
		}else{
					return false;
				}

			}else{
				//echo 'Erreur d\'execution de requette de selection';	
			}
			

		}

}
?>